package com.kerbores.blog.service.impl;

import java.util.List;

import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;

import com.kerbores.blog.bean.Tag;
import com.kerbores.blog.dao.ITagDao;
import com.kerbores.blog.service.ITagService;
import com.kerbores.utils.entries.Result;

/**
 * @author Ixion <br>
 *         create at 2014年10月26日
 */
@IocBean(name = "tagService")
public class TagServeiceImpl implements ITagService {

	@Inject
	private ITagDao tagDao;

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.kerbores.blog.service.ITagService#create(java.lang.String)
	 */
	@Override
	public Result create(String name) {
		Tag tag = new Tag(name);
		tag = tagDao.save(tag);
		if (tag == null) {
			return Result.fail("创建失败");
		}
		return Result.success().addData("tag", tag);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.kerbores.blog.service.ITagService#listAll()
	 */
	@Override
	public List<Tag> listAll() {
		return tagDao.findAll();
	}
}
